
import IUser from "./IUser";
// import { isString, isArray } from "../common/common";
import { isString } from "./common";
export class User implements IUser {
  // 属性
  private m_Myuser = "User";
  private m_id: string | null | undefined ="0";
  private m_name: string | null | undefined = "";
  private m_password: string | null | undefined = "";
  private m_email: string | null | undefined = "";
  private m_phonenumber: string | null | undefined = "";
  private m_userimg: string | null | undefined = "";

  constructor(user: IUser) {
    this.m_id = user.id;
    this.m_name = user.name;
    this.m_password = user.password;
    this.m_email = user.email;
    this.m_phonenumber = user.phonenumber;
    this.m_userimg = user.userimg;
  }
  [propName: string]:
    | null
    | string
    | number
    | undefined
    | (() => object);

  public get [Symbol.toStringTag]():
    | string
    | null
    | undefined
    | (() => object) {
    // return "[object " + this.m_Myuser + "]";
    return this.m_Myuser;
  }

  toJSON: () => object = () => {
    return {
      id: this.id,
      name: this.name,
      password: this.password,
      email: this.email,
      phonenumber: this.phonenumber,
      userimg: this.userimg
    };
  };

  public get className(): string {
    return this.m_Myuser;
  }
  public set className(value: string) {
    this.m_Myuser = value;
  }

  public get id(): string | null | undefined {
    return this.m_id;
  }
  public set id(value: string | null | undefined) {
    this.m_id = value;
  }
  public get name(): string | null | undefined {
    return this.m_name;
  }
  public set name(value: string | null | undefined) {
    if (isString(value) === true) {
      this.m_name = value;
    } else {
      this.m_name = "";
    }
  }
  public get password(): string | null | undefined {
    return this.m_password;
  }
  public set password(value: string | null | undefined) {
    if (isString(value) === true) {
      this.m_password = value;
    } else {
      this.m_password = "";
    }
  }
  public get email(): string | null | undefined {
    return this.m_email;
  }
  public set email(value: string | null | undefined) {
    if (isString(value) === true) {
      this.m_email = value;
    } else {
      this.m_email = "";
    }
  }
  public get phonenumber(): string | null | undefined {
    return this.m_phonenumber;
  }
  public set phonenumber(value: string | null | undefined) {
    if (isString(value) === true) {
      this.m_phonenumber = value;
    } else {
      this.m_phonenumber = "";
    }
  }
  public get userimg(): string | null | undefined {
    return this.m_userimg;
  }
  public set userimg(value: string | null | undefined) {
    if (isString(value) === true) {
      this.m_userimg = value;
    } else {
      this.m_userimg = "";
    }
  }
}
export default User;
